#include <bits/stdc++.h>
#define mem(x) memset(x,0,sizeof(x))
using namespace std;
const int mxn=1e5+10;
long double n,m,L,V,ans1,ans2,p;
long double d[mxn],v[mxn],a[mxn],vis[mxn];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    ios::sync_with_stdio(0);

    int T;
    cin>>T;
    while(T--){
        ans1=ans2=0;
        mem(vis);
        cin>>n>>m>>L>>V;
        bool fa=1;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]!=0){
                fa=0;
            }
        }
        if(fa){
            long double pp[mxn];
            long double ppmx=-1;
            for(int i=1;i<=m;i++){
                cin>>pp[i];
                ppmx=max(ppmx,pp[i]);
            }
            for(int i=1;i<=m;i++){
                if(d[i]<=ppmx&&v[i]>V){
                    ans1++;
                }
            }
            cout<<ans1<<" "<<1<<endl;
            continue;
        }
        for(int i=1;i<=m;i++){
            cin>>p;
            bool f=1;
            for(int j=1;j<=n;j++){
                if(d[j]<=p){
                    long double s=p-d[j];
                    long double v2=v[j]*v[j];
                    long double tpv=sqrt((long double)v2+2*a[j]*s);
                    if(tpv>V&&!vis[j]){
                        f=0;
                        vis[j]=1;
                        ans1++;
                    }
                }
            }
            if(f){
                ans2++;
            }
        }
        cout<<ans1<<" "<<ans2<<endl;
    }
    return 0;
}
